
<?php
include 'function.php';
error_reporting(0);//忽略数据库不存在报错
$sql = "select * from ST_UserInfo";
mssql_select_db ( $mssql_database, $conn );
$query = mssql_query ( $sql );
global $cz;
global $tk;
global $zs1;
global $zs2;
global $zs3;
global $zs4;
global $zs5;
?>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>尚客优品储值卡管理系统</title>
<link rel="stylesheet" type="text/css" href="css/common.css" />
<link rel="stylesheet" type="text/css" href="css/main.css" />
<script type="text/javascript" src="js/libs/modernizr.min.js"></script>
<script language="javascript" type="text/javascript" src="js/My97DatePicker/WdatePicker.js"></script>

</head>
<body>

		<div class="sidebar-wrap">
			<div class="sidebar-title">
				<h1>尚客优品</h1>
			</div>
			<div class="sidebar-content">
				<ul class="sidebar-list">
					<li><a href="#"><i class="icon-font">&#xe003;</i>常用操作</a>
						<ul class="sub-menu">
							<li><a href="index.php"><i class="icon-font">&#xe008;</i>收银报表</a></li>
							<li><a href="mx.php"><i class="icon-font">&#xe005;</i>收支明细</a></li>
							<li><a href="kmx.php"><i class="icon-font">&#xe006;</i>交易明细</a></li>
						</ul></li>
			</div>
		</div>
		<!--/sidebar-->
		<div class="main-wrap">
					<div class="crumb-wrap">
				<div class="crumb-list">
					<i class="icon-font"></i><a href="index.php" color="#white">首页</a><span
						class="crumb-step">&gt;</span><span class="crumb-name">收银报表</span>
				</div>
			</div>
			<!--/sidebar-->
			
			<div class="search-wrap">
				<div class="search-content">
					<form action="start.php" method="post">
						<table class="search-tab">
							<tr>
															<th width="70">选择职员:</th>
															
								<td><select name="employee" id="">
								<option value="0">全部</option>
										 <?php while ( $rst = mssql_fetch_assoc ( $query ) ) {
									     ?>
                                    <option value="<?php echo iconv ( 'gbk', 'utf-8', $rst [User_No] ); ?>">
                                    <?php echo iconv ( 'gbk', 'utf-8', $rst [User_Name] ); ?></option>
                                                                  <?php
                                                                          }
																	?>
                                </select></td>
								<th width="70">时间范围:</th>
								<td>
								<input name="start" type="text" onClick="WdatePicker()"/>
								</td>
								<td>~</td>
								<td>
								<input name="end" type="text" onClick="WdatePicker()"/>
								</td>
								<td><input class="btn btn-primary btn2" name="sub" onclick="window.open('start.php','_self')" value="初始化"
									type="submit"></td>
								
							</tr>
						</table>
					
					</form>
					
				</div>
			</div>
			<div class="result-wrap">
            <form name="myform" id="myform" method="post">
                
                <div class="result-content">
                    <table class="result-tab" width="50%">
                        
                        <tr>
                             <th> 时间段: (<?php echo $_COOKIE["s"].' '.'00:00:00';echo "~";echo $_COOKIE["e"].' '.'23:59:59' ; ?> )</th>
                            <th> 金额合计(<?php 
						
						 $sqlu = "select * from ST_UserInfo where User_No='$p'";
                           mssql_select_db ( $mssql_database, $conn );
                          $query = mssql_query ( $sqlu );
                          while ($rst = mssql_fetch_assoc ( $query ))
                        {
                        	echo iconv ( 'gbk', 'utf-8', $rst [User_Name] );
                        	
                        }
						
						
						?>)</th>
                                                 
                        </tr>
                        <tr>
                        <td>IC卡充值总金额</td>
                        <td><a href='mxb.php?id=cz'><?php 
                        $s=$_COOKIE["s"].' '.'00:00:00.000';
                        $e=$_COOKIE["e"].' '.'23:59:59.999';
						$p=$_COOKIE["p"];
						if ($p!=0){
                        $sql1="select SUM(Supply_Fund) as cz from ST_SupplyFund where Supply_Date between '$s' and '$e' and User_No='$p'";
						}
						else{
							$sql1="select SUM(Supply_Fund) as cz from ST_SupplyFund where Supply_Date between '$s' and '$e' ";
						}
                        mssql_select_db ( $mssql_database, $conn );
                        $query = mssql_query ( $sql1 );
                        while ($rst = mssql_fetch_assoc ( $query ))
                        {
                        	echo $rst[cz];
                        	$cz=$rst[cz];
                        	
                        }
                        
                        ?> </a>
						</td>
                        
                        </tr>
                        <tr>
                        <td>IC卡退款总金额</td>
                         <td><a href='mxb.php?id=tk'> <?php 
                        if ($p!=0){
                        $sql2="select SUM(Take_Fund) as tk from ST_TakeFund where Take_Date between '$s' and '$e' and User_No='$p'";
						}
						else{
							$sql2="select SUM(Take_Fund) as tk from ST_TakeFund where Take_Date between '$s' and '$e' ";
						}
                        mssql_select_db ( $mssql_database, $conn );
                        $query2 = mssql_query ( $sql2 );
                        while ($rst2 = mssql_fetch_assoc ( $query2 ))
                        {
                        	echo $rst2[tk];
                        	$tk=$rst2[tk];
                        	
                        }
                        
                        ?></a></td>
                        </tr>
                         <tr>
                        <td>满200赠送总金额</td>
                        <td> <a href='mxb.php?id=zs1'><?php 
						if ($p!=0){
                        $sql3="select SUM(Supply_Fund) as zs1 from ST_SupplyFund where Remark='1'and Supply_Date between '$s' and '$e' and User_No='$p'";
						}
						else{
						$sql3="select SUM(Supply_Fund) as zs1 from ST_SupplyFund where Remark='1'and Supply_Date between '$s' and '$e' ";
						}
                        mssql_select_db ( $mssql_database, $conn );
                        $query = mssql_query ( $sql3 );
                        while ($rst = mssql_fetch_assoc ( $query ))
                        {
                        	echo $rst[zs1];
                        	$zs1=$rst[zs1];
                        	
                        }
                        
                        ?></a></td>
                        </tr>
                         <tr>
                        <td>满300赠送总金额</td>
                        <td><a href='mxb.php?id=zs2'> <?php 
						if ($p!=0){
                        $sql4="select SUM(Supply_Fund) as zs2 from ST_SupplyFund where Remark='2' and Supply_Date between '$s' and '$e' and User_No='$p'";
						}
						else{
							$sql4="select SUM(Supply_Fund) as zs2 from ST_SupplyFund where Remark='2' and Supply_Date between '$s' and '$e' ";
						}
                        mssql_select_db ( $mssql_database, $conn );
                        $query = mssql_query ( $sql4 );
                        while ($rst = mssql_fetch_assoc ( $query ))
                        {
                        	echo $rst[zs2];
                        	$zs2=$rst[zs2];
                        }
                        
                        ?></a></td>
                        </tr>
						                         <tr>
                        <td>满500赠送总金额</td>
                        <td><a href='mxb.php?id=zs3'> <?php 
						if ($p!=0){
                        $sql4="select SUM(Supply_Fund) as zs3 from ST_SupplyFund where Remark='3' and Supply_Date between '$s' and '$e' and User_No='$p'";
						}
						else{
						$sql4="select SUM(Supply_Fund) as zs3 from ST_SupplyFund where Remark='3' and Supply_Date between '$s' and '$e'";	
						}
                        mssql_select_db ( $mssql_database, $conn );
                        $query = mssql_query ( $sql4 );
                        while ($rst = mssql_fetch_assoc ( $query ))
                        {
                        	echo $rst[zs3];
                        	$zs3=$rst[zs3];
                        }
                        
                        ?></a></td>
                        </tr>
						                         <tr>
                        <td>其他赠送总金额</td>
                        <td><a href='mxb.php?id=zs4'> <?php 
							if ($p!=0){
                        $sql4="select SUM(Supply_Fund) as zs4 from ST_SupplyFund where Remark='4' and Supply_Date between '$s' and '$e' and User_No='$p'";
							}
							else{
								$sql4="select SUM(Supply_Fund) as zs4 from ST_SupplyFund where Remark='4' and Supply_Date between '$s' and '$e' ";
							}
                        mssql_select_db ( $mssql_database, $conn );
                        $query = mssql_query ( $sql4 );
                        while ($rst = mssql_fetch_assoc ( $query ))
                        {
                        	echo $rst[zs4];
                        	$zs4=$rst[zs4];
                        }
                        
                        ?></a></td>
                        </tr>
						                         <tr>
                        <td>美团总金额</td>
                        <td><a href='mxb.php?id=zs5'> <?php
						if ($p!=0){
                        $sql4="select SUM(Supply_Fund) as zs5 from ST_SupplyFund where Remark='5' and Supply_Date between '$s' and '$e' and User_No='$p'";
						}
						else{
						$sql4="select SUM(Supply_Fund) as zs5 from ST_SupplyFund where Remark='5' and Supply_Date between '$s' and '$e' ";	
						}
                        mssql_select_db ( $mssql_database, $conn );
                        $query = mssql_query ( $sql4 );
                        while ($rst = mssql_fetch_assoc ( $query ))
                        {
                        	echo $rst[zs5];
                           $zs5=$rst[zs5]; 
                        }
                        
                        ?></a></td>
                        </tr>
                         <tr>
                        <td><?php 
						
						 $sqlu = "select * from ST_UserInfo where User_No='$p'";
                           mssql_select_db ( $mssql_database, $conn );
                          $query = mssql_query ( $sqlu );
                          while ($rst = mssql_fetch_assoc ( $query ))
                        {
                        	echo iconv ( 'gbk', 'utf-8', $rst [User_Name] );
                        	
                        }
						
						
						?>应交现金</td>
						
						
                        <td> <?php 
                        $xj=$cz-$tk-$zs1-$zs2-$zs3-$zs4-$zs5;
                        echo $xj;
                        ?></td>
                        </tr>
                    </table>
              
                </div>
            </form>
			
		<!--/main-->
	</div>
	
</body>
</html>